package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.ExamMapper;
import com.xxx.modules.entity.Exam;
import com.xxx.modules.service.ExamService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * exam
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@Service
public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements ExamService {

    @Autowired
    private ExamMapper examMapper;


    @Override
    public PageInfo<Exam> selectExamInfo(Exam exam, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Exam> wrapper = new QueryWrapper<>();
        List<Exam> data = examMapper.selectListInfo(exam);
        return new PageInfo<>(data);
    }

    @Override
    public void saveExamInfo(Exam exam) {
        exam.setCreateTime(TimeUtil.getCurrentTime());
        examMapper.insert(exam);
    }

    @Override
    public void updateExamInfo(Exam exam) {
        examMapper.updateById(exam);
    }

    @Override
    public void delExamInfo(Integer id) {
        examMapper.deleteById(id);
    }

    @Override
    public void delBatchExamInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        examMapper.deleteBatchIds(list);
    }


}